package operation;

import book.book;
import book.booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 666
 * Date: 2022-11-18
 * Time: 20:44
 */
public class Updateoperation implements Ioper{
    @Override
    public void work(booklist book) {
        System.out.println("请输入需要修改的书名");
        Scanner scanner = new Scanner(System.in);
        String name=scanner.nextLine();
        int cur=book.getBookSize();
        for (int i = 0; i < cur; i++) {
            book book1=  book.getBooks(i);
            if (book1.getName().equals(name)){
                System.out.println("请输入需要修改为的书名");
                String name1=scanner.nextLine();
                book1.setName(name1);
                System.out.println("请输入作者名");
                String author=scanner.nextLine();
                book1.setAuthor(author);
                System.out.println("请输入书的类型");
                String type=scanner.nextLine();
                book1.setType(type);
                System.out.println("请输入价格");
                int price=scanner.nextInt();
                book1.setPrice(price);
                System.out.println("修改成功");
             return;
            }

        }
        System.out.println("该书不存在，修改失败");

    }

}
